package org.vectrics.recruiter.reporting;




//import com.lowagie.text.*;
import java.util.Locale;

import com.lowagie.text.Rectangle;
import com.lowagie.text.PageSize;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import org.apache.log4j.Logger;
import org.vectrics.SystemException;
import org.vectrics.VectricsException;
import org.vectrics.domain.Domain;


public class JobStatisticSummaryReport extends RecruitBaseReport {
	private transient static Logger log = Logger.getLogger(JobStatisticSummaryReport.class);
    private int startYear = 2006;
	private int previousYearCount = 5;
	
	
	public JobStatisticSummaryReport(Domain domain, Locale locale) {
		super(domain, locale);
	}
	
	@Override
	protected Rectangle getPageSize() {
		return(PageSize.A4.rotate());
		//return(PageSize.A4);
	}


	protected void addSectionSeparation(Document document) {
		try {
			document.add(new Paragraph(" ", ReportConstants.titleFont));
		} catch (Exception ex) {
			throw new SystemException("Exception adding paragraph", ex);
		}
	}
	 
	@Override
	protected void fill(Document document) throws VectricsException {
		log.debug("Job List Report - building");
		TimeQuery timeQuery = new CreatedJobsStatQuery();
		this.addYearlyStatTable(timeQuery, "report.header.created.stat.summary", document);

		timeQuery = new PostedJobsStatQuery();
		this.addYearlyStatTable(timeQuery, "report.header.posted.stat.summary", document);

		timeQuery = new PostedInternalJobsStatQuery();
		this.addYearlyStatTable(timeQuery, "report.header.posted.internal.stat.summary", document);

		timeQuery = new PostedPublicJobsStatQuery();
		this.addYearlyStatTable(timeQuery, "report.header.posted.public.stat.summary", document);
	}
	
	protected void addYearlyStatTable(TimeQuery timeQuery, String headerCode, Document document) {
		try {
			this.addSectionSeparation(document);
			JobStatisticSummaryPdfTable statTable = new JobStatisticSummaryPdfTable(
					this.getDomain(), this.getLocale(),
					this.startYear, this.previousYearCount, timeQuery, headerCode);
			statTable.fill();
			document.add(statTable.getTable());
		} catch (Exception ex) {
			throw new SystemException("Exception creating report", ex);
		}
		
	}

    
	protected void setupHeaderFooter(Document document) throws VectricsException {
		//
	}


	


}
